#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>

#include "modulestabdialog.h"

ModulesTabDialog::ModulesTabDialog(const ModuleList &moduleList, QWidget *parent) :
    QDialog(parent)
{
    tabWidget = new QTabWidget;

    foreach(ModuleManifest* Module, moduleList)
    {
        QWidget *wdgt = new QWidget;
        tabWidget->addTab(wdgt, Module->Name());
        QVBoxLayout *Layout = new QVBoxLayout;

        SettingsList settingsList = Module->Settings();
        foreach(node_settings setting, settingsList)
        {
            if (setting.visible != "true")
                continue;

            Layout->addWidget(new QLabel(setting.label));
            Layout->addWidget(new QLineEdit(setting.value));

            wdgt->setLayout(Layout);
        }
    }

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(tabWidget);
    mainLayout->addWidget(buttonBox);
    mainLayout->setSizeConstraint(QLayout::SetNoConstraint);

    setLayout(mainLayout);
    setWindowTitle("Настройки модулей");
}

void ModulesTabDialog::accept()
{
    //
}
